\(\int \frac {\sec (c+d x) (A+B \sec (c+d x)+C \sec ^2(c+d x))}{(a+a \sec (c+d x))^2} \, dx\) [461]

   Optimal result
   Rubi [A] (verified)
   Mathematica [B] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [F]
   Maxima [B] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 39, antiderivative size = 81 \[ \int \frac {\sec (c+d x) \left (A+B \sec (c+d x)+C \sec ^2(c+d x)\right )}{(a+a \sec (c+d x))^2} \, dx=\frac {C \text {arctanh}(\sin (c+d x))}{a^2 d}+\frac {(A+2 B-5 C) \tan (c+d x)}{3 a^2 d (1+\sec (c+d x))}+\frac {(A-B+C) \tan (c+d x)}{3 d (a+a \sec (c+d x))^2} \]

[Out]

C*arctanh(sin(d*x+c))/a^2/d+1/3*(A+2*B-5*C)*tan(d*x+c)/a^2/d/(1+sec(d*x+c))+1/3*(A-B+C)*tan(d*x+c)/d/(a+a*sec(
d*x+c))^2

Rubi [A] (verified)

Time = 0.19 (sec) , antiderivative size = 87, normalized size of antiderivative = 1.07, number of steps used = 4, number of rules used = 4, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.103, Rules used = {4163, 4083, 3855, 3879} \[ \int \frac {\sec (c+d x) \left (A+B \sec (c+d x)+C \sec ^2(c+d x)\right )}{(a+a \sec (c+d x))^2} \, dx=\frac {(2 A+B-4 C) \tan (c+d x)}{3 a^2 d (\sec (c+d x)+1)}+\frac {C \text {arctanh}(\sin (c+d x))}{a^2 d}-\frac {(A-B+C) \tan (c+d x) \sec (c+d x)}{3 d (a \sec (c+d x)+a)^2} \]

[In]

Int[(Sec[c + d*x]*(A + B*Sec[c + d*x] + C*Sec[c + d*x]^2))/(a + a*Sec[c + d*x])^2,x]

[Out]

(C*ArcTanh[Sin[c + d*x]])/(a^2*d) + ((2*A + B - 4*C)*Tan[c + d*x])/(3*a^2*d*(1 + Sec[c + d*x])) - ((A - B + C)
*Sec[c + d*x]*Tan[c + d*x])/(3*d*(a + a*Sec[c + d*x])^2)

Rule 3855

Int[csc[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-ArcTanh[Cos[c + d*x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3879

Int[csc[(e_.) + (f_.)*(x_)]/(csc[(e_.) + (f_.)*(x_)]*(b_.) + (a_)), x_Symbol] :> Simp[-Cot[e + f*x]/(f*(b + a*
Csc[e + f*x])), x] /; FreeQ[{a, b, e, f}, x] && EqQ[a^2 - b^2, 0]

Rule 4083

Int[(csc[(e_.) + (f_.)*(x_)]*(csc[(e_.) + (f_.)*(x_)]*(B_.) + (A_)))/(csc[(e_.) + (f_.)*(x_)]*(b_.) + (a_)), x
_Symbol] :> Dist[B/b, Int[Csc[e + f*x], x], x] + Dist[(A*b - a*B)/b, Int[Csc[e + f*x]/(a + b*Csc[e + f*x]), x]
, x] /; FreeQ[{a, b, e, f, A, B}, x] && NeQ[A*b - a*B, 0]

Rule 4163

Int[csc[(e_.) + (f_.)*(x_)]*((A_.) + csc[(e_.) + (f_.)*(x_)]*(B_.) + csc[(e_.) + (f_.)*(x_)]^2*(C_.))*(csc[(e_
.) + (f_.)*(x_)]*(b_.) + (a_))^(m_), x_Symbol] :> Simp[(-(a*A - b*B + a*C))*Cot[e + f*x]*Csc[e + f*x]*((a + b*
Csc[e + f*x])^m/(a*f*(2*m + 1))), x] - Dist[1/(a*b*(2*m + 1)), Int[Csc[e + f*x]*(a + b*Csc[e + f*x])^(m + 1)*S
imp[a*B - b*C - 2*A*b*(m + 1) - (b*B*(m + 2) - a*(A*(m + 2) - C*(m - 1)))*Csc[e + f*x], x], x], x] /; FreeQ[{a
, b, e, f, A, B, C}, x] && LtQ[m, -1] && EqQ[a^2 - b^2, 0]

Rubi steps \begin{align*} \text {integral}& = -\frac {(A-B+C) \sec (c+d x) \tan (c+d x)}{3 d (a+a \sec (c+d x))^2}+\frac {\int \frac {\sec (c+d x) (a (2 A+B-C)+3 a C \sec (c+d x))}{a+a \sec (c+d x)} \, dx}{3 a^2} \\ & = -\frac {(A-B+C) \sec (c+d x) \tan (c+d x)}{3 d (a+a \sec (c+d x))^2}+\frac {(2 A+B-4 C) \int \frac {\sec (c+d x)}{a+a \sec (c+d x)} \, dx}{3 a}+\frac {C \int \sec (c+d x) \, dx}{a^2} \\ & = \frac {C \text {arctanh}(\sin (c+d x))}{a^2 d}-\frac {(A-B+C) \sec (c+d x) \tan (c+d x)}{3 d (a+a \sec (c+d x))^2}+\frac {(2 A+B-4 C) \tan (c+d x)}{3 d \left (a^2+a^2 \sec (c+d x)\right )} \\ \end{align*}

Mathematica [B] (verified)

Leaf count is larger than twice the leaf count of optimal. \(219\) vs. \(2(81)=162\).

Time = 2.31 (sec) , antiderivative size = 219, normalized size of antiderivative = 2.70 \[ \int \frac {\sec (c+d x) \left (A+B \sec (c+d x)+C \sec ^2(c+d x)\right )}{(a+a \sec (c+d x))^2} \, dx=-\frac {4 \cos \left (\frac {1}{2} (c+d x)\right ) \left (C+B \cos (c+d x)+A \cos ^2(c+d x)\right ) \left (6 C \cos ^3\left (\frac {1}{2} (c+d x)\right ) \left (\log \left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right )-\log \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )\right )+(A-B+C) \sec \left (\frac {c}{2}\right ) \sin \left (\frac {d x}{2}\right )-2 (2 A+B-4 C) \cos ^2\left (\frac {1}{2} (c+d x)\right ) \sec \left (\frac {c}{2}\right ) \sin \left (\frac {d x}{2}\right )+(A-B+C) \cos \left (\frac {1}{2} (c+d x)\right ) \tan \left (\frac {c}{2}\right )\right )}{3 a^2 d (1+\cos (c+d x))^2 (A+2 C+2 B \cos (c+d x)+A \cos (2 (c+d x)))} \]

[In]

Integrate[(Sec[c + d*x]*(A + B*Sec[c + d*x] + C*Sec[c + d*x]^2))/(a + a*Sec[c + d*x])^2,x]

[Out]

(-4*Cos[(c + d*x)/2]*(C + B*Cos[c + d*x] + A*Cos[c + d*x]^2)*(6*C*Cos[(c + d*x)/2]^3*(Log[Cos[(c + d*x)/2] - S
in[(c + d*x)/2]] - Log[Cos[(c + d*x)/2] + Sin[(c + d*x)/2]]) + (A - B + C)*Sec[c/2]*Sin[(d*x)/2] - 2*(2*A + B
- 4*C)*Cos[(c + d*x)/2]^2*Sec[c/2]*Sin[(d*x)/2] + (A - B + C)*Cos[(c + d*x)/2]*Tan[c/2]))/(3*a^2*d*(1 + Cos[c
+ d*x])^2*(A + 2*C + 2*B*Cos[c + d*x] + A*Cos[2*(c + d*x)]))

Maple [A] (verified)

Time = 0.17 (sec) , antiderivative size = 79, normalized size of antiderivative = 0.98

method result size
parallelrisch \(\frac {-6 C \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )+6 C \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )-\tan \left (\frac {d x}{2}+\frac {c}{2}\right ) \left (\left (A -B +C \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2}-3 A -3 B +9 C \right )}{6 a^{2} d}\) \(79\)
derivativedivides \(\frac {2 C \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )-2 C \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )-\frac {\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{3} A}{3}+\frac {\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{3} B}{3}-\frac {\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{3} C}{3}+\tan \left (\frac {d x}{2}+\frac {c}{2}\right ) B +\tan \left (\frac {d x}{2}+\frac {c}{2}\right ) A -3 \tan \left (\frac {d x}{2}+\frac {c}{2}\right ) C}{2 d \,a^{2}}\) \(116\)
default \(\frac {2 C \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )-2 C \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )-\frac {\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{3} A}{3}+\frac {\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{3} B}{3}-\frac {\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{3} C}{3}+\tan \left (\frac {d x}{2}+\frac {c}{2}\right ) B +\tan \left (\frac {d x}{2}+\frac {c}{2}\right ) A -3 \tan \left (\frac {d x}{2}+\frac {c}{2}\right ) C}{2 d \,a^{2}}\) \(116\)
risch \(\frac {2 i \left (3 A \,{\mathrm e}^{2 i \left (d x +c \right )}-3 C \,{\mathrm e}^{2 i \left (d x +c \right )}+3 A \,{\mathrm e}^{i \left (d x +c \right )}+3 B \,{\mathrm e}^{i \left (d x +c \right )}-9 C \,{\mathrm e}^{i \left (d x +c \right )}+2 A +B -4 C \right )}{3 d \,a^{2} \left ({\mathrm e}^{i \left (d x +c \right )}+1\right )^{3}}+\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right ) C}{a^{2} d}-\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right ) C}{a^{2} d}\) \(135\)
norman \(\frac {-\frac {\left (A -B +C \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{7}}{6 a d}+\frac {\left (A -3 C +B \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{2 a d}+\frac {\left (5 A +B -7 C \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{5}}{6 a d}-\frac {\left (7 A +5 B -17 C \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{3}}{6 a d}}{\left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2}-1\right )^{2} a}+\frac {C \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}{a^{2} d}-\frac {C \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}{a^{2} d}\) \(167\)

[In]

int(sec(d*x+c)*(A+B*sec(d*x+c)+C*sec(d*x+c)^2)/(a+a*sec(d*x+c))^2,x,method=_RETURNVERBOSE)

[Out]

1/6*(-6*C*ln(tan(1/2*d*x+1/2*c)-1)+6*C*ln(tan(1/2*d*x+1/2*c)+1)-tan(1/2*d*x+1/2*c)*((A-B+C)*tan(1/2*d*x+1/2*c)
^2-3*A-3*B+9*C))/a^2/d

Fricas [A] (verification not implemented)

none

Time = 0.29 (sec) , antiderivative size = 133, normalized size of antiderivative = 1.64 \[ \int \frac {\sec (c+d x) \left (A+B \sec (c+d x)+C \sec ^2(c+d x)\right )}{(a+a \sec (c+d x))^2} \, dx=\frac {3 \, {\left (C \cos \left (d x + c\right )^{2} + 2 \, C \cos \left (d x + c\right ) + C\right )} \log \left (\sin \left (d x + c\right ) + 1\right ) - 3 \, {\left (C \cos \left (d x + c\right )^{2} + 2 \, C \cos \left (d x + c\right ) + C\right )} \log \left (-\sin \left (d x + c\right ) + 1\right ) + 2 \, {\left ({\left (2 \, A + B - 4 \, C\right )} \cos \left (d x + c\right ) + A + 2 \, B - 5 \, C\right )} \sin \left (d x + c\right )}{6 \, {\left (a^{2} d \cos \left (d x + c\right )^{2} + 2 \, a^{2} d \cos \left (d x + c\right ) + a^{2} d\right )}} \]

[In]

integrate(sec(d*x+c)*(A+B*sec(d*x+c)+C*sec(d*x+c)^2)/(a+a*sec(d*x+c))^2,x, algorithm="fricas")

[Out]

1/6*(3*(C*cos(d*x + c)^2 + 2*C*cos(d*x + c) + C)*log(sin(d*x + c) + 1) - 3*(C*cos(d*x + c)^2 + 2*C*cos(d*x + c
) + C)*log(-sin(d*x + c) + 1) + 2*((2*A + B - 4*C)*cos(d*x + c) + A + 2*B - 5*C)*sin(d*x + c))/(a^2*d*cos(d*x
+ c)^2 + 2*a^2*d*cos(d*x + c) + a^2*d)

Sympy [F]

\[ \int \frac {\sec (c+d x) \left (A+B \sec (c+d x)+C \sec ^2(c+d x)\right )}{(a+a \sec (c+d x))^2} \, dx=\frac {\int \frac {A \sec {\left (c + d x \right )}}{\sec ^{2}{\left (c + d x \right )} + 2 \sec {\left (c + d x \right )} + 1}\, dx + \int \frac {B \sec ^{2}{\left (c + d x \right )}}{\sec ^{2}{\left (c + d x \right )} + 2 \sec {\left (c + d x \right )} + 1}\, dx + \int \frac {C \sec ^{3}{\left (c + d x \right )}}{\sec ^{2}{\left (c + d x \right )} + 2 \sec {\left (c + d x \right )} + 1}\, dx}{a^{2}} \]

[In]

integrate(sec(d*x+c)*(A+B*sec(d*x+c)+C*sec(d*x+c)**2)/(a+a*sec(d*x+c))**2,x)

[Out]

(Integral(A*sec(c + d*x)/(sec(c + d*x)**2 + 2*sec(c + d*x) + 1), x) + Integral(B*sec(c + d*x)**2/(sec(c + d*x)
**2 + 2*sec(c + d*x) + 1), x) + Integral(C*sec(c + d*x)**3/(sec(c + d*x)**2 + 2*sec(c + d*x) + 1), x))/a**2

Maxima [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 190 vs. \(2 (77) = 154\).

Time = 0.24 (sec) , antiderivative size = 190, normalized size of antiderivative = 2.35 \[ \int \frac {\sec (c+d x) \left (A+B \sec (c+d x)+C \sec ^2(c+d x)\right )}{(a+a \sec (c+d x))^2} \, dx=-\frac {C {\left (\frac {\frac {9 \, \sin \left (d x + c\right )}{\cos \left (d x + c\right ) + 1} + \frac {\sin \left (d x + c\right )^{3}}{{\left (\cos \left (d x + c\right ) + 1\right )}^{3}}}{a^{2}} - \frac {6 \, \log \left (\frac {\sin \left (d x + c\right )}{\cos \left (d x + c\right ) + 1} + 1\right )}{a^{2}} + \frac {6 \, \log \left (\frac {\sin \left (d x + c\right )}{\cos \left (d x + c\right ) + 1} - 1\right )}{a^{2}}\right )} - \frac {B {\left (\frac {3 \, \sin \left (d x + c\right )}{\cos \left (d x + c\right ) + 1} + \frac {\sin \left (d x + c\right )^{3}}{{\left (\cos \left (d x + c\right ) + 1\right )}^{3}}\right )}}{a^{2}} - \frac {A {\left (\frac {3 \, \sin \left (d x + c\right )}{\cos \left (d x + c\right ) + 1} - \frac {\sin \left (d x + c\right )^{3}}{{\left (\cos \left (d x + c\right ) + 1\right )}^{3}}\right )}}{a^{2}}}{6 \, d} \]

[In]

integrate(sec(d*x+c)*(A+B*sec(d*x+c)+C*sec(d*x+c)^2)/(a+a*sec(d*x+c))^2,x, algorithm="maxima")

[Out]

-1/6*(C*((9*sin(d*x + c)/(cos(d*x + c) + 1) + sin(d*x + c)^3/(cos(d*x + c) + 1)^3)/a^2 - 6*log(sin(d*x + c)/(c
os(d*x + c) + 1) + 1)/a^2 + 6*log(sin(d*x + c)/(cos(d*x + c) + 1) - 1)/a^2) - B*(3*sin(d*x + c)/(cos(d*x + c)
+ 1) + sin(d*x + c)^3/(cos(d*x + c) + 1)^3)/a^2 - A*(3*sin(d*x + c)/(cos(d*x + c) + 1) - sin(d*x + c)^3/(cos(d
*x + c) + 1)^3)/a^2)/d

Giac [A] (verification not implemented)

none

Time = 0.32 (sec) , antiderivative size = 144, normalized size of antiderivative = 1.78 \[ \int \frac {\sec (c+d x) \left (A+B \sec (c+d x)+C \sec ^2(c+d x)\right )}{(a+a \sec (c+d x))^2} \, dx=\frac {\frac {6 \, C \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 1 \right |}\right )}{a^{2}} - \frac {6 \, C \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 1 \right |}\right )}{a^{2}} - \frac {A a^{4} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - B a^{4} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} + C a^{4} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - 3 \, A a^{4} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 3 \, B a^{4} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 9 \, C a^{4} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )}{a^{6}}}{6 \, d} \]

[In]

integrate(sec(d*x+c)*(A+B*sec(d*x+c)+C*sec(d*x+c)^2)/(a+a*sec(d*x+c))^2,x, algorithm="giac")

[Out]

1/6*(6*C*log(abs(tan(1/2*d*x + 1/2*c) + 1))/a^2 - 6*C*log(abs(tan(1/2*d*x + 1/2*c) - 1))/a^2 - (A*a^4*tan(1/2*
d*x + 1/2*c)^3 - B*a^4*tan(1/2*d*x + 1/2*c)^3 + C*a^4*tan(1/2*d*x + 1/2*c)^3 - 3*A*a^4*tan(1/2*d*x + 1/2*c) -
3*B*a^4*tan(1/2*d*x + 1/2*c) + 9*C*a^4*tan(1/2*d*x + 1/2*c))/a^6)/d

Mupad [B] (verification not implemented)

Time = 15.89 (sec) , antiderivative size = 83, normalized size of antiderivative = 1.02 \[ \int \frac {\sec (c+d x) \left (A+B \sec (c+d x)+C \sec ^2(c+d x)\right )}{(a+a \sec (c+d x))^2} \, dx=\frac {2\,C\,\mathrm {atanh}\left (\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\right )}{a^2\,d}-\frac {\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\left (\frac {A-B+C}{2\,a^2}-\frac {2\,A-2\,C}{2\,a^2}\right )}{d}-\frac {{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^3\,\left (A-B+C\right )}{6\,a^2\,d} \]

[In]

int((A + B/cos(c + d*x) + C/cos(c + d*x)^2)/(cos(c + d*x)*(a + a/cos(c + d*x))^2),x)

[Out]

(2*C*atanh(tan(c/2 + (d*x)/2)))/(a^2*d) - (tan(c/2 + (d*x)/2)*((A - B + C)/(2*a^2) - (2*A - 2*C)/(2*a^2)))/d -
 (tan(c/2 + (d*x)/2)^3*(A - B + C))/(6*a^2*d)